//
//  XLViewController.m
//  25frames
//
//  Created by liang xie on 10/22/15.
//  Copyright © 2015 xieliang. All rights reserved.
//

#import "XLViewController.h"

@interface XLViewController ()

@end

@implementation XLViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    [self setLeftBarButtonItem];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

- (void)setRightBarButtonItemWithImage:(UIImage*)image target:(id)target selector:(SEL)selector{
    UIBarButtonItem *item = [[UIBarButtonItem alloc] initWithImage:image style:UIBarButtonItemStylePlain target:target action:selector];
    self.navigationItem.rightBarButtonItem = item;
}

- (void)setLeftBarButtonItem{
    
    NSArray *cons = [self.navigationController viewControllers];
    if ([cons firstObject] == self) {
        //如果当前是controller是navicontroller的rootviewcontroller
        UIBarButtonItem *item = [[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"icon_nav_menu"] style:UIBarButtonItemStylePlain target:self action:@selector(showMenu)];
        self.navigationItem.leftBarButtonItem = item;
    }
}

- (IBAction)showMenu {
    [self.mm_drawerController toggleDrawerSide:MMDrawerSideLeft animated:YES completion:nil];
}

@end
